package com.qqserver.service;

import com.qqcommon.Message;

import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;

/**
 *     该类用来存放离线消息
 */
@SuppressWarnings({"all"})
public class OffLineMessage {
    //key为用户id,v为离线信息
    private static ConcurrentHashMap<String, ArrayList<Message>> offLineDb=new ConcurrentHashMap<>();

    /**
     *
     * @param getterId 接受消息的用户ID
     * @param messages 离线消息
     */
    public static void addOffLineDb(String getterId,ArrayList<Message> messages){
        offLineDb.put(getterId,messages);
    }

    //根据用户名,得到消息集合
    public static ArrayList<Message> getArrayList(String getter){
        return offLineDb.get(getter);
    }

    public static ConcurrentHashMap<String, ArrayList<Message>> getOffLineDb() {
        return offLineDb;
    }
    //根据用户名删除离线消息集合
    public static void remove(String getterID){
        offLineDb.remove(getterID);
    }
}
